// let module = {
//   _raw: "用户写的是什么样子",
//   _children: {
//     a: {
//       _raw: "a模块用户的样子",
//       _children: {
//         c: {},
//       },
//       state: a.state,
//     },
//     b: "儿子",
//   },
//   state: rootModule.state,
// };

import { forEachValue } from "../utils"


class Module {
    constructor(rootModule){
      this._raw = rootModule,
      this._children = {},
      this.state = rootModule.state
    }
    getChild(key){
      return this._children[key]
    }
    addChild(key,module){
      this._children[key] = module
    }
    forEachMutation(cb){
        if(this._raw.mutations){
            forEachValue(this._raw.mutations,cb)
        }
    }
    forEachAction(cb){
      if(this._raw.actions){
          forEachValue(this._raw.actions,cb)
      }
  }
    forEachChildren(cb){
        forEachValue(this._children,cb)
    }
  }

  export default Module